#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
int main(int argc, char *argv[])
{
	struct stat st;
	stat(argv[1],&st);
	if(argc != 2 )
	{
		printf("Please enter Filename after mystat!\n");
		return 0;
	}
	printf("  文件：%s\n",argv[1]);
	printf("  大小：%ld            块：%ld          IO 块：%ld   ",(long)st.st_size,(long)st.st_blocks,(long)st.st_blksize);
	switch (st.st_mode & S_IFMT)
    {
    case S_IFBLK:
        printf("块设备\n");
        break;
    case S_IFDIR:
        printf("目录\n");
        break;
    case S_IFIFO:
        printf("管道\n");
        break;
    case S_IFLNK:
        printf("链接\n");
        break;
    case S_IFREG:
        printf("普通文件\n");
        break;
    default:
        printf("文件类型不确定\n");
        break;
    }
	printf("设备：%lxh/%lud        Inode：%ld      硬链接：%ld\n",st.st_dev,st.st_dev,(long)st.st_ino,(long)st.st_nlink);
	printf("权限：(0664/-rw-rw-r--)");
    	printf("  Uid：( %ld/     lqy)   Gid：( %ld/     lqy)\n", (long)st.st_uid, (long)st.st_gid);
    	printf("最近访问：%s", ctime(&st.st_atime));
    	printf("最近更改：%s", ctime(&st.st_mtime));
    	printf("最近改动：%s", ctime(&st.st_ctime));
    	printf("创建时间：-\n") ; 
	return 0;
}
